layui.use(['form','layer','laydate','table','laytpl'],function(){
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : top.layer,
        $ = layui.jquery,
        laydate = layui.laydate,
        laytpl = layui.laytpl,
        table = layui.table;
//列表
    var tableIns = table.render({
        elem: '#stateList',
        url : '/errLog/getErrorList',
        cellMinWidth : 95,
        page : true,
        height : "full-125",
        limit : 10,
        limits : [10,15,20,25],
        id : "stateListTable",
        cols : [[
            {field: 'ip', title: 'IP', align:"center"},
            {field: 'userName', title: '用户',align:"center"},
            {field: 'className', title: '类名', align:'center'},
            {field: 'methodName', title: '方法名',  align:'center'},
            {field: 'errorType', title: '错误类型', align:'center'},
            {field: 'creatTime', title: '时间', align:'center'},
            {title: '操作', templet:'#stateListBar',fixed:"right",align:"center"}
        ]]
    });
    
    
//    错误详情
    function stateEdit(edit){
        var index = layui.layer.open({
            title : "错误详情",
            type : 2,
            content : "/errLog/errDeil?errorId="+edit.errorId
        })
        layui.layer.full(index);
        //改变窗口大小时，重置弹窗的宽高，防止超出可视区域（如F12调出debug的操作）
        $(window).on("resize",function(){
            layui.layer.full(index);
        })
    }
    //列表操作
    table.on('tool(stateList)', function(obj){
        var layEvent = obj.event,
            data = obj.data;

        if(layEvent === 'edit'){ //编辑
            stateEdit(data);
        }else if(layEvent === 'already'){
        	
        	layer.confirm('确定已解决？',{icon:3, title:'提示信息'},function(index){
            	if(index){
            		$.get("/errLog/deleteMsg?errorId="+data.errorId,function(result){
            			if(result.success){
            				layer.msg("删除成功");  
            				tableIns.reload();
            			}else{
            				layer.open({
            					title: '温馨提示'
            					,content: result.message
            				});     
            				tableIns.reload();
            			};
            		});
            		
            	}else{
            		tableIns.reload();
            	};
            });
        	
        }
    });
	
})

